package ooday03;

public class RefArrayDemo {
    public static void main(String[] args) {
        //声明Dog型数组dogs，包含3个元素，每个元素都是Dog类型，默认值为null
//        Dog[] dogs = new Dog[3];
//        //声明Chick型数组chick，包含3个元素，每个元素都是Chick类型，默认值为null
//        Chick[] chicks=new Chick[3];
//        //声明Fish型数组fish，包含2个元素，每个元素都是Fish类型，默认值为null
//        Fish[] fish=new Fish[2];

        Dog[] dogs = new Dog[3];
        dogs[0]=new Dog("小鹿",1,"金");
        dogs[1] =new Dog("小白",1,"黑");
        dogs[2] =new Dog("小黑",2,"白");

        for (int i=0;i< dogs.length;i++){
           System.out.println(dogs[i].name);
              dogs[i].swim();
        }
        Chick[] chicks=new Chick[2];
        chicks[0]=new Chick("烤鸡",1,"黄");
        chicks[1]=new Chick("炸鸡",2,"金");

        for (int i=0;i< chicks.length;i++){
            System.out.println(chicks[i].name);
            chicks[i].layEggs();
        }
        Fish[] fish=new Fish[3];
        fish[0]=new Fish("烤鱼",1,"白");
        fish[1]=new Fish("酸菜鱼",2,"褐");
        fish[2]=new Fish("糖醋鲤鱼",2,"金");
        for (int i=0;i<fish.length;i++){
            System.out.println(fish[i].name);
            fish[i].eat();
        }
    }
}
